package org.wu.framework.inner.lazy.orm.solon.config;

import lombok.Data;

import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Condition;
import org.noear.solon.annotation.Configuration;
import org.wu.framework.inner.lazy.orm.solon.prop.LazyDataSourceSolonProperties;

import javax.sql.DataSource;

/**
 * description 懒人数据源配置 (可选)
 * 默认使用 MysqlDataSource
 *
 * @author Jia wei Wu
 * @date 2021/4/23 下午1:39
 */
@Data
@Configuration
@Condition(onProperty = "solon.datasource.url")
public class LazyDataSourceSolonAutoConfiguration {


    /**
     * description 添加懒人数据源配置
     *
     * @param lazyDataSourceSolonProperties 数据源连接配置
     * @return datasource
     * @author Jia wei Wu
     * @date 2021/4/23 下午1:54
     */
    @Bean(name = "lazyDataSource")
//    @Condition(onMissingBean = DataSource.class)
    public DataSource lazyDataSource(LazyDataSourceSolonProperties lazyDataSourceSolonProperties) {
        return lazyDataSourceSolonProperties.getDatasource();
    }


}
